﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Plantillanoheader.master" AutoEventWireup="true"  CodeFile="AddEditArticulos.aspx.cs" Inherits="PagAdmin_AddEditArticulos" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Src="~/controles/FileUploader.ascx" TagName="FileUploader" TagPrefix="mb" %>
<%@ Register Src="~/controles/RatingDisplay.ascx" TagName="RatingDisplay" TagPrefix="mb" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="../Styles/calendar.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="headerslider" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="bodyprincipal" Runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" 
    EnableScriptGlobalization="True">
    </asp:ScriptManager>
<asp:ObjectDataSource ID="objCurrArticle" runat="server" DeleteMethod="DeleteArticle"
      InsertMethod="InsertArticle" SelectMethod="GetArticleByID" TypeName="IUAP.BLL.Articulo.Articulo"
      UpdateMethod="UpdateArticulo">
      <DeleteParameters>
         <asp:Parameter Name="id" Type="Int32" />
      </DeleteParameters>
      <UpdateParameters>
         <asp:Parameter Name="id" Type="Int32" />
         <asp:Parameter Name="id_categoria" Type="Int32" />
         <asp:Parameter Name="titu_arti" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="resu_arti" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="cont_arti" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="ciud_arti" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="fech_publ_arti" Type="DateTime" />
         <asp:Parameter Name="fech_expi_arti" Type="DateTime" />
         <asp:Parameter Name="apro_arti" Type="Boolean" />
         <asp:Parameter Name="list_arti" Type="Boolean" />
         <asp:Parameter Name="actv_comn_arti" Type="Boolean" />
         <asp:Parameter Name="solo_miem_arti" Type="Boolean" />
      </UpdateParameters>
      <SelectParameters>
         <asp:QueryStringParameter Name="id_articulo" QueryStringField="ID" Type="Int32" />
      </SelectParameters>
      <InsertParameters>
         <asp:Parameter Name="id_categoria" Type="Int32" />
         <asp:Parameter Name="titu_arti" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="resu_arti" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="cont_arti" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="ciud_arti" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="fech_publ_arti" Type="DateTime" />
         <asp:Parameter Name="fech_expi_arti" Type="DateTime" />
         <asp:Parameter Name="apro_arti" Type="Boolean" />
         <asp:Parameter Name="list_arti" Type="Boolean" />
         <asp:Parameter Name="actv_comn_arti" Type="Boolean" />
         <asp:Parameter Name="solo_miem_arti" Type="Boolean" />
      </InsertParameters>
   </asp:ObjectDataSource>
   <asp:ObjectDataSource ID="objAllCategories" runat="server" SelectMethod="GetCategories"
    TypeName="IUAP.BLL.Articulo.Categoria">
   </asp:ObjectDataSource>
      <asp:ObjectDataSource ID="objAllCiudad" runat="server" SelectMethod="GetCiudad"
      TypeName="IUAP.Helpers">
      <SelectParameters>
         <asp:Parameter DefaultValue="true" Name="insertEmpty" Type="Boolean" />
      </SelectParameters>
   </asp:ObjectDataSource>
<div>
<h3>
      <asp:Literal runat="server" ID="lblNewArticle" Text="Postear Nuevo Artículo" />
      <asp:Literal runat="server" ID="lblEditArticle" Text="Editar Artículo" Visible="false" />
</h3>
</div>
<p></p>
<asp:DetailsView ID="dvwArticle" runat="server" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True"
      AutoGenerateInsertButton="True" AutoGenerateRows="False" DataKeyNames="ID" DataSourceID="objCurrArticle"
      DefaultMode="Insert" HeaderText="" 
        OnItemCreated="dvwArticle_ItemCreated" OnDataBound="dvwArticle_DataBound" 
        OnModeChanged="dvwArticle_ModeChanged" Width="602px" SkinID="Articulo">
      <FieldHeaderStyle Width="100px" />
      <Fields>
         <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
            SortExpression="Id" />
         <asp:BoundField DataField="Fecha" HeaderText="Fecha" InsertVisible="False"
            ReadOnly="True" SortExpression="Fecha" DataFormatString="{0:f}" />
         <asp:BoundField DataField="Usuario" HeaderText="Usuario" InsertVisible="False" ReadOnly="True"
            SortExpression="Usuario" />
         <asp:BoundField DataField="Cont_visi_arti" HeaderText="Visitas" InsertVisible="False"
            ReadOnly="True" SortExpression="Cont_visi_arti" />
         <asp:BoundField DataField="Voto_arti" HeaderText="Votos" InsertVisible="False" ReadOnly="True"
            SortExpression="Voto_arti" />
         <asp:BoundField DataField="Rank_arti" HeaderText="Rating" InsertVisible="False"
            DataFormatString="{0:N2}" ReadOnly="True" SortExpression="Rank_arti" />
         <asp:TemplateField HeaderText="Categoria" SortExpression="Id_categoria">
            <ItemTemplate>
               <asp:Label ID="lblCategory" runat="server" Text='<%# Eval("titu_cate") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
               <asp:DropDownList CssClass="genselect" ID="ddlCategories" runat="server" DataSourceID="objAllCategories"
                  DataTextField="Titu_cate" DataValueField="ID" SelectedValue='<%# Bind("id_categoria") %>' Width="100%" />
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Titulo" SortExpression="Titu_arti">
            <ItemTemplate>
               <asp:Label ID="lblTitle" runat="server" Text='<%# Eval("titu_arti") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
               <asp:TextBox CssClass="gentextbox" ID="txtTitle" runat="server" Text='<%# Bind("titu_arti") %>' Width="100%" MaxLength="256"></asp:TextBox>
               <asp:RequiredFieldValidator ID="valRequireTitle" runat="server" ControlToValidate="txtTitle" SetFocusOnError="true"
                  Text="El campo de título es necesario." ToolTip="El campo de título es necesario." Display="Dynamic"></asp:RequiredFieldValidator>
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Resumen" SortExpression="Resu_arti">
            <ItemTemplate>
               <asp:Label ID="lblAbstract" runat="server" Text='<%# Eval("resu_arti") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
               <asp:TextBox CssClass="gentextbox" ID="txtAbstract" runat="server" Text='<%# Bind("resu_arti") %>' Rows="5" TextMode="MultiLine" Width="100%" MaxLength="4000"></asp:TextBox>
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Contenido" SortExpression="Cont_arti">
            <ItemTemplate>
               <asp:Label ID="lblBody" runat="server" Text='<%# Eval("cont_arti") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <CKEditor:CKEditorControl ID="CKEditorControl1" runat="server" BasePath="~/ckeditor/" Text='<%# Bind("cont_arti") %>' Height="300px" Width="100%" DefaultLanguage="es" Toolbar="Full"></CKEditor:CKEditorControl>
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Ciudad" SortExpression="Ciud_arti">
            <ItemTemplate>
               <asp:Label ID="lblCountry" runat="server" Text='<%# Eval("ciud_arti") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
               <asp:DropDownList CssClass="genselect" ID="ddlCountries" runat="server" DataTextField="Value" DataValueField="Key"
                  DataSourceID="objAllCiudad" SelectedValue='<%# Bind("ciud_arti") %>' Width="100%" MaxLength="256"/>
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Fecha de Publicación" SortExpression="Fecha_publ_arti">
            <ItemTemplate>
               <asp:Label ID="lblReleaseDate" runat="server" Text='<%# Eval("fech_publ_arti", "{0:d}") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
               <asp:TextBox CssClass="gentextbox" ID="txtReleaseDate" runat="server" Text='<%# Bind("fech_publ_arti", "{0:d}") %>' Width="30%"></asp:TextBox>               
               <input type="image" id="imgcalendar" src="../Images/calendar.png" alt="Calendario" style="border-width:0px;" />
                <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtReleaseDate"
                CssClass="cal_Theme1" Format="dd/MM/yyyy" PopupButtonID="imgcalendar" PopupPosition="BottomRight">
                </asp:CalendarExtender>
                <asp:CompareValidator runat="server" ID="valReleaseDateType" ControlToValidate="txtReleaseDate"
                  SetFocusOnError="true" Display="Dynamic" Operator="DataTypeCheck" Type="Date"
                  Text="El formato de la fecha de publicación no es válido." 
                  ToolTip="El formato de la fecha de publicación no es válido." />
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Fecha de Expiración" SortExpression="Fech_expi_arti">
            <ItemTemplate>
               <asp:Label ID="lblExpireDate" runat="server" Text='<%# Eval("fech_expi_arti", "{0:d}") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
               <asp:TextBox CssClass="gentextbox" ID="txtExpireDate" runat="server" Text='<%# Bind("fech_expi_arti", "{0:d}") %>' Width="30%"></asp:TextBox>
               <input type="image" id="imgcalendar2" src="../Images/calendar.png" alt="Calendario" style="border-width:0px;" />
                <asp:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtExpireDate"
                CssClass="cal_Theme1" Format="dd/MM/yyyy" PopupButtonID="imgcalendar2" PopupPosition="BottomRight">
                </asp:CalendarExtender>
               <asp:CompareValidator runat="server" ID="valExpireDateType" ControlToValidate="txtExpireDate"
                  SetFocusOnError="true" Display="Dynamic" Operator="DataTypeCheck" Type="Date"
                  Text="El formato de la fecha de expiración no es válido." 
                  ToolTip="El formato de la fecha de expiración no es válido." />
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Aprobado" SortExpression="Apro_arti">
            <ItemTemplate>
               <asp:CheckBox ID="chkApproved" runat="server" Checked='<%# Eval("apro_arti") %>' Enabled="False" />
            </ItemTemplate>
            <EditItemTemplate>
               <asp:CheckBox ID="chkApproved" runat="server" Checked='<%# Bind("apro_arti") %>' />
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Lista" SortExpression="List_arti">
            <ItemTemplate>
               <asp:CheckBox ID="chkListed" runat="server" Checked='<%# Eval("list_arti") %>' Enabled="False" />
            </ItemTemplate>
            <EditItemTemplate>
               <asp:CheckBox ID="chkListed" runat="server" Checked='<%# Bind("list_arti") %>' />
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Comentarios Activos" SortExpression="Actv_comn_arti">
            <ItemTemplate>
               <asp:CheckBox ID="chkCommentsEnabled" runat="server" Checked='<%# Eval("actv_comn_arti") %>' Enabled="False" />
            </ItemTemplate>
            <EditItemTemplate>
               <asp:CheckBox ID="chkCommentsEnabled" runat="server" Checked='<%# Bind("actv_comn_arti") %>' />
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="Sólo para miembros" SortExpression="solo_miem_arti">
            <ItemTemplate>
               <asp:CheckBox ID="chkOnlyForMembers" runat="server" Checked='<%# Eval("solo_miem_arti") %>' Enabled="False"/>
            </ItemTemplate>
            <EditItemTemplate>
               <asp:CheckBox ID="chkOnlyForMembers" runat="server" Checked='<%# Bind("solo_miem_arti") %>'/>
            </EditItemTemplate>
         </asp:TemplateField>         
      </Fields>
   </asp:DetailsView>
   <p></p>
   <mb:FileUploader id="FileUploader1" runat="server">
   </mb:FileUploader>  
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="titulocolum" Runat="Server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="bodycolleft" Runat="Server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="bodycolright" Runat="Server">
</asp:Content>
